
import math

class fl_Speed_exp:
    def __init__(self):
        self.x_sv = 0
        self.y_sv = 0
        self.z_sv = 0
        self.s_sv = 0

def LLM_ComputeUnloadSpeed(FLSpeed_BEST, UNLOAD_SPEED, fl_Speed_now):
    fl_Speed_exp = fl_Speed_exp()
    
    if abs(fl_Speed_now.x_speed) > FLSpeed_BEST:
        if fl_Speed_now.x_speed > 0:
            fl_Speed_exp.x_sv = fl_Speed_now.x_speed - UNLOAD_SPEED
        else:
            fl_Speed_exp.x_sv = fl_Speed_now.x_speed + UNLOAD_SPEED
    
    if abs(fl_Speed_now.y_speed) > FLSpeed_BEST:
        if fl_Speed_now.y_speed > 0:
            fl_Speed_exp.y_sv = fl_Speed_now.y_speed - UNLOAD_SPEED
        else:
            fl_Speed_exp.y_sv = fl_Speed_now.y_speed + UNLOAD_SPEED
    
    if abs(fl_Speed_now.z_speed) > FLSpeed_BEST:
        if fl_Speed_now.z_speed > 0:
            fl_Speed_exp.z_sv = fl_Speed_now.z_speed - UNLOAD_SPEED
        else:
            fl_Speed_exp.z_sv = fl_Speed_now.z_speed + UNLOAD_SPEED
    
    if abs(fl_Speed_now.s_speed) > FLSpeed_BEST:
        if fl_Speed_now.s_speed > 0:
            fl_Speed_exp.s_sv = fl_Speed_now.s_speed - UNLOAD_SPEED
        else:
            fl_Speed_exp.s_sv = fl_Speed_now.s_speed + UNLOAD_SPEED
    
    return fl_Speed_exp
